﻿Imports Microsoft.Crm.Workflow

<CrmWorkflowActivity("toPunycode", "String Utilities")> _
Public Class toPunycode
    Inherits SequenceActivity
    Public Shared PunycodeOutputProperty As DependencyProperty = DependencyProperty.Register("PunycodeOutput", GetType(String), GetType(toPunycode))
    <CrmOutput("Punycode")> _
    Public Property PunycodeOutput() As [String]
        Get
            Return DirectCast(MyBase.GetValue(PunycodeOutputProperty), [String])
        End Get
        Set(ByVal value As [String])
            MyBase.SetValue(PunycodeOutputProperty, value)
        End Set
    End Property

    Public Shared IDNInputProperty As DependencyProperty = DependencyProperty.Register("IDNInput", GetType(String), GetType(toPunycode))
    <CrmInput("IDN")> _
    Public Property IDNInput() As [String]
        Get
            Return DirectCast(MyBase.GetValue(IDNInputProperty), [String])
        End Get
        Set(ByVal value As [String])
            MyBase.SetValue(IDNInputProperty, value)
        End Set
    End Property

    Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus
        Dim IDNmapping As New System.Globalization.IdnMapping
        PunycodeOutput = IDNmapping.GetAscii(IDNInput)
        Return MyBase.Execute(executionContext)
    End Function
End Class

